feat(scripting): add zod schemas and viem transform helpers#690
Open
feat(scripting): add zod schemas and viem transform helpers#690
Conversation
Add zod v4 validation schemas and transform functions for all SDK operations. Includes shared primitives (address, hex, bigint schemas), per-function schema/transform pairs, and viem client factory helpers.
Abitype's peer dep on zod ^3 caused pnpm to keep zod@3.22.4 in the tree, creating non-portable abitype resolution paths that TypeScript couldn't name in .d.ts output.
Rename gasOverrideOptionsSchema -> gasOptionsSchema, gasOverridesSchema -> gasLimitSchema, retryableGasOverridesSchema -> tokenBridgeRetryableGasOverridesSchema. Reorder hexSchema and privateKeySchema in common.ts. Use destructuring + spread in 9 transforms to reduce repetitive input field assignments.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
no-issue
All together on: #686
Summary
Adds zod schemas and transforms for every SDK function that takes RPC/client input. Schemas validate JSON input and transforms convert it to SDK-ready arguments -- RPC URLs become viem clients, private keys become accounts, strings become bigints. The target audience here is devs who are already familiar with zod, and helping them to write scripts without messing up the arg parsing, and letting them follow a opinionated structure. Devs who arent familiar with zod dont get benefit here, but it's not a complicated library to learn, and I think it's a useful thing to know about.
WARNING: we're creating schemas for every function, so there's a lot of code being added here, but two things are worth focusing on which help us to gain confidence in the correctness of the code:
Not included for now